<div class="pm-check-container">

    <div class="right">
        <nz-card [nzBordered]="false">
            <form nz-form [nzLayout]="'inline'" [formGroup]="searchForm">
                <nz-form-item>
                    <nz-form-label>时间</nz-form-label>
                    <nz-form-control>
                        <nz-range-picker formControlName="rangePickerTime" [nzAllowClear]="false"
                            [nzPlaceHolder]="['起始日期', '截止日期']"></nz-range-picker>
                    </nz-form-control>

                </nz-form-item>
                <nz-form-item>
                    <nz-form-label>关键字</nz-form-label>
                    <nz-form-control>
                        <input type="text" nz-input formControlName="keywords">
                    </nz-form-control>
                </nz-form-item>

                <nz-form-item>
                    <nz-form-control>
                        <button nz-button nzType="primary" (click)="queryInfo(true)"><i nz-icon nzType="search"></i>查询
                        </button>
                        <button nz-button nzType="primary" (click)="openEditModal()" style="margin-left: 10px">新增
                        </button>
                    </nz-form-control>
                </nz-form-item>
            </form>

            <div class="table-wrap">
                <nz-table #dataTable nzSize="small" [nzTotal]="total" [nzFrontPagination]="false"
                    [(nzPageIndex)]="pageNum" [(nzPageSize)]="pageSize" [nzLoading]="loading"
                    (nzPageIndexChange)="queryInfo()" [nzData]="tableData">
                    <thead>
                        <tr>
                            <th>开始日期</th>
                            <th>任务名称</th>
                            <th>执行人员</th>
                            <th>来源</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <ng-template ngFor let-data [ngForOf]="dataTable.data">
                            <tr>
                                <td>{{ data.begindate }}</td>
                                <td>{{ data.taskname }}</td>
                                <td>{{ data.staffid }}</td>
                                <td>
                                    <div *ngIf="data.source==='0'">PC</div>
                                    <div *ngIf="data.source==='1'">App</div>

                                </td>
                                <td>
                                    <div *ngIf="data.state==='0'">未开始</div>
                                    <div *ngIf="data.state==='1'">执行中</div>
                                    <div *ngIf="data.state==='2'">待审核</div>
                                    <div *ngIf="data.state==='3'">已完成</div>
                                </td>
                                <td>
                                    <a (click)="openEditModal(data)">编辑</a>
                                    <nz-divider nzType="vertical"></nz-divider>
                                    <a nz-popconfirm nzPopconfirmTitle="确认删除？" nzPopconfirmPlacement="left"
                                        (nzOnConfirm)="onDelete(data.taskid)">
                                        删除
                                    </a>
                                </td>
                            </tr>
                            <tr [nzExpand]="true"
                                [ngClass]="{'green': data.resultstate === '1', 'red': data.resultstate === '2'}">
                                <td colspan="5">维护结果： {{ data.result }}</td>
                            </tr>
                        </ng-template>
                    </tbody>
                </nz-table>
            </div>
        </nz-card>
    </div>

    <nz-modal nzClassName="custom-modal" nzWidth="760" [(nzVisible)]="modalShow" [nzTitle]="modalTitle"
        (nzOnCancel)="onCancel()" (nzOnOk)="onConfirm()">
        <form nz-form [formGroup]="checkForm">
            <div nz-row [nzGutter]="24">
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">维护对象</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <!--                            <nz-select formControlName="objid"-->
                            <!--                                       nzPlaceHolder="维护对象">-->
                            <!--                                <nz-option *ngFor="let item of projectList"-->
                            <!--                                           [nzLabel]="item.name"-->
                            <!--                                           [nzValue]="item.id">-->
                            <!--                                </nz-option>-->
                            <!--                            </nz-select>-->
                            <input type="text" nz-input formControlName="objid">

                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">任务名称</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <input nz-input formControlName="taskname" placeholder="任务名称">
                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">任务描述</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <input nz-input formControlName="taskdesc" placeholder="任务描述">
                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">地址</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <input nz-input formControlName="manageName" placeholder="地址">
                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">来源</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <nz-select formControlName="source" nzPlaceHolder="来源">
                                <nz-option nzLabel="PC" nzValue="0"></nz-option>
                                <nz-option nzLabel="App" nzValue="1"></nz-option>
                            </nz-select>
                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">执行人员</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                         
                            <input type="text" nz-input formControlName="staffid">

                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">开始时间</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <nz-date-picker formControlName="begindate" nzShowTime nzFormat="yyyy-MM-dd"
                                nzPlaceHolder="开始时间"></nz-date-picker>
                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">结束时间</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <nz-date-picker formControlName="enddate" nzShowTime nzFormat="yyyy-MM-dd"
                                nzPlaceHolder="结束时间"></nz-date-picker>
                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">任务状态</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <nz-select formControlName="state" nzPlaceHolder="任务状态">-->
                                <nz-option nzLabel="未开始" nzValue="0"></nz-option>
                                <nz-option nzLabel="执行中" nzValue="1"></nz-option>
                                <nz-option nzLabel="待审核" nzValue="2"></nz-option>
                                <nz-option nzLabel="已完成" nzValue="3"></nz-option>
                            </nz-select>
                            <!-- <input type="text" nz-input formControlName="state"> -->

                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="12">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="6">维护结果状态</nz-form-label>
                        <nz-form-control [nzSpan]="16">
                            <nz-select formControlName="resultstate" nzPlaceHolder="巡检结果状态">
                                <nz-option nzLabel="正常" nzValue="1"></nz-option>
                                <nz-option nzLabel="异常" nzValue="2"></nz-option>
                            </nz-select>

                        </nz-form-control>
                    </nz-form-item>
                </div>
                <div nz-col [nzSpan]="24">
                    <nz-form-item nzFlex>
                        <nz-form-label [nzSpan]="3">维护结果</nz-form-label>
                        <nz-form-control [nzSpan]="20">
                            <textarea formControlName="result" nz-input rows="2"></textarea>
                        </nz-form-control>
                    </nz-form-item>
                </div>
            </div>
        </form>
    </nz-modal>

</div>